package com.lktx.sso.admin.entity;

import com.mybatisflex.annotation.*;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

/** SSO用户表 - sso_user */
@Data
@Table("sso_user")
public class SsoUser {
    @Id(value = "sso_user_id", keyType = KeyType.Auto)
    private Integer ssoUserId;
    /*组织ID*/
    private Integer ssoOrganizationId;
    /**头像*/
    private String avatar;
    /**用户姓名*/
    private String name;
    /**用户昵称*/
    private String nickname;
    /**用户登录名*/
    private String username;
    /**手机号*/
    private String phone;
    /**邮箱*/
    private String email;
    /**密码*/
    private String password;
    /**来源*/
    private String source;
    /**是否冻结 0 启用 1 禁用*/
    private Integer locked;
    /**用户描述*/
    private String remark;
    /**是否逻辑删除*/
    @Column(isLogicDelete = true)
    private Integer deleted;
    /**创建时间*/
    @Column(onInsertValue = "now()")
    private LocalDateTime createTime;
    /**更新时间*/
    @Column(onUpdateValue = "now()", onInsertValue = "now()")
    private LocalDateTime updateTime;

    @RelationOneToOne(selfField = "ssoOrganizationId", targetField = "ssoOrganizationId")
    private SsoOrganization ssoOrganization;

    @RelationManyToMany(
            joinTable = "sso_user_job",
            selfField = "ssoUserId", joinSelfColumn = "user_id",
            targetField = "id", joinTargetColumn = "job_id"
    )
    private List<SsoJob> jobs;

    @Column(ignore = true)
    private List<Integer> jobIds;

}